<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>零活</title>
    <link rel="stylesheet" type="text/css" href="../../../../css/aui/aui.css" />
    <style>
        #header {
            display: flex;
            align-items: center;
            justify-content: space-around;
            background: #F5F5F5;
            padding: .75rem 0;
        }

        #header div {
            text-align: center;
        }

        #header div span {
            margin-right: .3rem;
        }

        .triangle {
            padding: 0;
            display: inline-block;
            width: 0;
            height: 0;
            border-right: 0.35rem solid transparent;
            border-left: 0.35rem solid transparent;
            border-top: 0.35rem solid black;
        }

        .aui-list {
            background: rgba(0, 0, 0, 0);
            box-shadow: 0 0 3px #ccc;
        }

        .aui-list .aui-list-item {
            min-height: 1.8rem;
            border-bottom: 1px solid #eeeeee;
            background: rgba(0, 0, 0, 0)
        }

        .aui-list .aui-list-item-inner {
            min-height: 1.8rem;
        }

        .person_info {
            display: flex;
            flex-direction: column;
            justify-content: center;
            font-size: 0.6rem;
            line-height: 1.1rem;
        }

        .list_box {
            border-bottom: 1px solid #eeeeee;
            margin-bottom: 1rem;
        }

        .iconimg {
            width: 0.6rem;
            display: inline-block;
        }

        .aui-list .aui-list-item-media img {
            border: 1px solid #ECECEC;
            border-radius: 100%;
            width: 3rem;
            height: 3rem;
        }
    </style>
</head>

<body>
    <div class="aui-content" id="app">
        <div id="header">
            <div class="area" @click="openCity()"><span>{{userRegion.area}}</span><span class="triangle"></span></div>
        </div>
        <div class="aui-content-padded">
            <div class="aui-list list_box" @click="particulars(v.work_id)" v-for="v in list">
                <div class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title aui-ellipsis-1">{{v.title}}</div>
                    </div>
                </div>
                <div class="aui-list-item">
                    <div class="aui-media-list-item-inner">
                        <div class="aui-list-item-media">
                            <img :src="v.headimgurl">
                        </div>
                        <div class="person_info">
                            <div> <img src="../../../../image/icon/menu02-1.png" class="iconimg" alt=""> <span>联系人：{{v.contact}}</span></div>
                            <div> <img src="../../../../image/icon/daohang.png" class="iconimg" alt=""> <span>项目地点：{{v.region}}</span></div>
                            <div> <img src="../../../../image/icon/time.png" class="iconimg" alt=""> <span>发布时间：{{v.work_date}}</span></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script src="../../../../script/api.js" charset="utf-8"></script>
<script src="../../../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../../../script/common/common.js" charset="utf-8"></script>
<script src="../../../../script/common/config.js" charset="utf-8"></script>
<script src="../../../../script/common/vue.min.js" charset="utf-8"></script>
<script>
    var stateBarH = '';
    apiready = function() {
        api.parseTapmode();

        //沉浸式状态栏
        var systemType = api.systemType;
        var statusBar = api.require('statusBar');
        if (systemType == "ios") {
            if (navigator.userAgent.indexOf("iPhone") != -1) {
                stateBarH = api.safeArea.top;
            }
        } else {
            statusBar.getStatusBarHeight(function(ret, err) {
                stateBarH = ret.statusHeight;
            });
        }

        vm.init();
    }

    var vm = new Vue({
        el: "#app",
        data: {
            userRegion: {},
            list: [],
            title: '',
            pages: 1
        },
        methods: {
            init() {
                this.userRegion = get_local('user_region');
                this.page();
                this.getListData();
            },
            getListData() {
                var self = this;
                _ajax(Config.api.AmateurGetLists, {
                    region_areaid: self.userRegion.areaid,
                    title: self.title,
                    pages: self.pages
                }, function(res) {
                    if (res.code === 200) {
                        if (res.data.length === 0) {
                            $toast('数据已加载完毕');
                            self.pages = -1;
                        } else {
                            self.list = self.list.concat(res.data);
                        }
                    }
                });
            },
            page() {
                // 下拉刷新
                var self = this;
                push_down(function() {
                    //下拉刷新恢复
                    push_down_over();

                    self.pages = 1;
                    self.list = [];
                    self.getListData();
                });

                //上拉加载
                push_up(function() {
                    if (self.pages === -1) {
                        $toast('数据已加载完毕');
                    } else {
                        ++self.pages;
                        self.getListData();
                    }
                });
            },
            particulars(id) {
                if (isLogin()) {
                    open_w('particulars_win', './particulars_win.html', {
                        id: id
                    });
                }
            },
            openCity() {
                api.openFrame({
                    name: 'mask',
                    url: '../../../city/city_win.html',
                    rect: {
                        x: 0,
                        y: stateBarH,
                        w: 'auto',
                        h: 'auto'
                    },
                    bgColor: 'rgba(0,0,0,0.5)',
                    pageParam: {
                        name: api.winName,
                        frameName: api.frameName,
                        provinceid: this.userRegion.provinceid,
                        cityid: this.userRegion.cityid,
                        areaid: this.userRegion.areaid
                    }
                });
            }
        }
    });

    function setCity(province, city, area) {
        var data = {
            "provinceid": province.code,
            "province": province.name,
            "cityid": city.code,
            "city": city.name,
            "areaid": area.code,
            "area": area.name
        };
        vm.userRegion = data;
        vm.pages = 1;
        vm.list = [];
        vm.getListData();
    }

    function search(cont) {
        vm.title = cont;
        vm.pages = 1;
        vm.list = [];
        vm.getListData();
    }
</script>

</html>
